from django.db import models
    
class Tag(models.Model):
    name = models.CharField(max_length=30)
    def __unicode__(self):
        return self.name

class Restriction(models.Model):
    name = models.CharField(max_length=30)
    def __unicode__(self):
        return self.name

class Variable(models.Model):
    name = models.CharField(max_length=30)
    symbol = models.CharField(max_length=10)
    si_units = models.CharField(max_length=30)
    other_units = models.CharField(max_length=100)
    def __unicode__(self):
        return self.name

class Index_card(models.Model):
    title = models.CharField(max_length=100)
    author = models.CharField(max_length=10)
    tags = models.ManyToManyField(Tag)
    slug = models.SlugField(primary_key=True)    
    equation = models.CharField(max_length=400)
    variables = models.ManyToManyField(Variable)
    restrictions = models.ManyToManyField(Restriction)
    details = models.CharField(max_length=1000)
    pub_date = models.DateTimeField('date published')
    reference = models.CharField(max_length=400)
    image = models.ImageField(
        'Attach Image',
        upload_to='postimg/',
        blank=True
    )
    def __unicode__(self):
        return self.title
